<?Php if(is_array($partList)){?>
<ul>
    <?php foreach ($partList as $key=>$rs){?>
    <li class="material_Li"  onclick="getsku(<?=$key?>,'<?=$mtId?>','<?=$productId?>')" style="margin-top: -5px">
            <a href="javascript:void(0)">
                <?php
                if($rs['products_name_cn']=='') {
                    $rs['products_name_cn'] = $rs['products_name'];
                }
                if($rs['products_name']==''){
                    $rs['products_name']=$rs['products_name_cn'];
                }
                ?>
                <?=$this->uri->segment(1)=='sc'?$rs['products_name_cn']:$rs['products_name']?>
                <span style="color: #0000FF;margin-left: 5px;font-size: 14px;" id="sku<?=$key?>"><?=$rs['sku']?></span>
                <input type="hidden" id="sap_sku<?=$key?>" value="<?=$rs['sap_sku']?>">
                <input type="hidden" id="products_name<?=$key?>" value="<?=$rs['products_name']?>">
                <input type="hidden" id="products_name_cn<?=$key?>" value="<?=$rs['products_name_cn']?>">
                <input type="hidden" id="products_price<?=$key?>" value="<?=$rs['products_price']?>">
                <input type="hidden" id="products_cost<?=$key?>" value="<?=$rs['products_cost']?>">
                <input type="hidden" id="currency<?=$key?>" value="<?=$rs['currency']?>">
            </a>
    </li>
    <?php }?>
</ul>
<?php }?>
<script type="text/javascript" src="<?=base_url()?>resource/js/layer/layer.js"></script>
<script type="text/javascript">
    function getsku(id,mtId,pid){
        var sap_sku=$('#sap_sku'+id).val();
        var index=layer.load(2);
        $.post("<?=blang_url('ajax/ajax/ajaxMaterialOne')?>",{'sap_sku':sap_sku,'productId':pid},function(data){
            if(data) {
                layer.close(index);
                $("input[name='accessory_name']").val($('#products_name' + id).val());
                $("input[name='sku']").val($('#sku' + id).text());
                $("input[name='accessory_price']").val($('#products_price' + id).val());
                $("input[name='purchase_source']").val($('#currency' + id).val());
                $("input[name='accessory_cost']").val($('#products_cost' + id).val());
                $("#currency").text($('#currency' + id).val());
                $("#cucy").val($('#currency' + id).val());
                $("#search_auto").css({'display': 'none'});
                if (data > 0) {
                    $("input[name='quantity']").val(data);
                } else {
                    $("input[name='quantity']").val(0);
                    $("#name_cn").val($('#products_name_cn' + id).val());
                    $('#mt_site').val(mtId);
                    $('#loadingDiv').css('display', 'block');
                    $('#yjieguo').css('display', 'block');
                    $('#mjieguo').css('display', 'none');
                    $('#popup').slideDown();
                }
            }
        });
        $(document).on('click','a',function(){
            if($(this).text()=="确定" || $(this).text()=="Determine"){
                if($("#number1").val()==''){
                    alert("<?=lang('pcm_slbnwk')?>");
                    return false;
                }
                if(isNaN($("#number1").val())){
                    alert("<?=lang('pcm_slbxssz')?>");
                    return false;
                }
                $("#caigou1").submit();
            }else{
                $('#loadingDiv').css('display','none');
                $('#popup').slideUp();
            }
        });
    }

</script>
